package com.papper.common.bean.sys;

import com.papper.common.bean.BaseEntity;
import com.papper.common.utils.tool.StringTool;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
import java.util.List;

/**
 * @Author:LaJiao
 * @Date:2017-08-03 14:31:11
 * @Description:系统模块资源表
 */
@Table(name = "sys_resource")
public class SysResource extends BaseEntity {
	// 自增ID
	@Id
	@GeneratedValue(generator = "JDBC")
	private Long              id;
	// 所属系统
	@Column(name = "system_id")
	private Integer           systemId;
	// 所属模块
	@Column(name = "model_id")
	private Integer           modelId;
	// 资源类型
	@Column(name = "res_type")
	private Integer           resType;
	// 资源名称
	@Column(name = "res_name")
	private String            resName;
	// 资源访问路径
	@Column(name = "res_url")
	private String            resUrl;
	// 扩展权限
	@Column(name = "res_limit")
	private String            resLimit;
	// 资源描述
	@Column(name = "res_desc")
	private String            resDesc;
	// 资源图标
	@Column(name = "res_icon")
	private String            resIcon;
	// 排序
	@Column(name = "res_sort")
	private Integer           resSort;
	// 执行事件
	@Column(name = "res_event")
	private String            resEvent;
	// 限制IP
	@Column(name = "res_ip")
	private String            resIp;
	// 限制SESSION
	@Column(name = "res_session")
	private String            resSession;
	// 父ID
	@Column(name = "up_id")
	private Integer           upId;
	// 层级树
	@Column(name = "up_family")
	private String            upFamily;
	// 子级数
	@Column(name = "up_child")
	private Integer           upChild;
	// 数据状态
	@Column(name = "data_status")
	private Integer           dataStatus;
	// 创建时间
	@Column(name = "create_time")
	private Date              createTime;
	// 更新时间
	@Column(name = "modify_time")
	private Date              modifyTime;
	@Transient
	private Integer           resLevel;
	@Transient
	private List<SysResource> childs;
	@Transient
	private Integer           limitValue = 0;

	/**
	 * get/set
	 */
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Integer getSystemId() {
		return systemId;
	}

	public void setSystemId(Integer systemId) {
		this.systemId = systemId;
	}

	public Integer getModelId() {
		return modelId;
	}

	public void setModelId(Integer modelId) {
		this.modelId = modelId;
	}

	public Integer getResType() {
		return resType;
	}

	public void setResType(Integer resType) {
		this.resType = resType;
	}

	public String getResName() {
		return resName;
	}

	public void setResName(String resName) {
		this.resName = resName;
	}

	public String getResUrl() {
		return resUrl;
	}

	public void setResUrl(String resUrl) {
		this.resUrl = resUrl;
	}

	public String getResLimit() {
		return resLimit;
	}

	public void setResLimit(String resLimit) {
		this.resLimit = resLimit;
	}

	public String getResDesc() {
		return resDesc;
	}

	public void setResDesc(String resDesc) {
		this.resDesc = resDesc;
	}

	public String getResIcon() {
		return resIcon;
	}

	public void setResIcon(String resIcon) {
		this.resIcon = resIcon;
	}

	public Integer getResSort() {
		return resSort;
	}

	public void setResSort(Integer resSort) {
		this.resSort = resSort;
	}

	public String getResEvent() {
		return resEvent;
	}

	public void setResEvent(String resEvent) {
		this.resEvent = resEvent;
	}

	public String getResIp() {
		return resIp;
	}

	public void setResIp(String resIp) {
		this.resIp = resIp;
	}

	public String getResSession() {
		return resSession;
	}

	public void setResSession(String resSession) {
		this.resSession = resSession;
	}

	public Integer getUpId() {
		return upId;
	}

	public void setUpId(Integer upId) {
		this.upId = upId;
	}

	public String getUpFamily() {
		return upFamily;
	}

	public void setUpFamily(String upFamily) {
		this.upFamily = upFamily;
	}

	public Integer getUpChild() {
		return upChild;
	}

	public void setUpChild(Integer upChild) {
		this.upChild = upChild;
	}

	public Integer getDataStatus() {
		return dataStatus;
	}

	public void setDataStatus(Integer dataStatus) {
		this.dataStatus = dataStatus;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Date getModifyTime() {
		return modifyTime;
	}

	public void setModifyTime(Date modifyTime) {
		this.modifyTime = modifyTime;
	}

	public Integer getResLevel() {
		return resLevel;
	}

	public void setResLevel(Integer resLevel) {
		this.resLevel = resLevel;
	}

	public Integer getLimitValue() {
		return limitValue;
	}

	public void setLimitValue(Integer limitValue) {
		this.limitValue = limitValue;
	}

	public List<SysResource> getChilds() {
		return childs;
	}

	public void setChilds(List<SysResource> childs) {
		this.childs = childs;
	}

	public String getSortFamily() {
		return StringTool.nullToEmpty(upFamily).replace("," + id, "");
	}
}